<%@ page language="java"
         contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="java.util.Map"
         import="java.util.List"
         import="com.shxt.hotel.background.*"
%>
<%
    Room roomManager = new Room();    
    User userManager = new User();
    Consume consumeManager = new Consume();
    
    if(session.getAttribute("id") == null){
        response.sendRedirect("./login.jsp");
    }else{
        Map<String, Object> currentUser = userManager.getUserInfo((int)session.getAttribute("id"));
%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <link rel="shortcut icon" href="../Public/img/favicon.html">

    <title>Profile</title>

    <!-- Bootstrap core CSS -->
    <link href="../Public/css/bootstrap.min.css" rel="stylesheet">
    <link href="../Public/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="../Public/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="../Public/css/style.css" rel="stylesheet">
    <link href="../Public/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="../Public/js/html5shiv.js"></script>
      <script src="../Public/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>

    <section id="container" class="">
        <!--header start-->
        <jsp:include page="./Public/header.jsp" flush="true" />
        <!--header end-->
        <!--sidebar start-->
        <jsp:include page="./Public/sidebar.jsp" flush="true" />
        <!--sidebar end-->
        <!--main content start-->
        <section id="main-content">
            <section class="wrapper">
                <!-- page start-->
                <div class="row">
                    <aside class="profile-nav col-lg-3">
                        <section class="panel">
                            <div class="user-heading round">
                                <a href="#">
                                    <img src="../Public/img/profile-avatar.jpg" alt="">
                                </a>
                                <h1><%=currentUser.get("username") %></h1>
                                <p><%=currentUser.get("phone") %></p>
                            </div>

                            <ul class="nav nav-pills nav-stacked">
                                <li class="active">
                                    <a href="user_profiles.jsp"> <i class="icon-user"></i> Profile</a>
                                </li>
                                <li>
                                    <a href="user_edit.jsp"> <i class="icon-edit"></i> Edit profile</a>
                                </li>
                            </ul>

                        </section>
                    </aside>
                    <aside class="profile-info col-lg-9">
                        <section class="panel">
                            <form>
                                <textarea placeholder="Whats in your mind today?" rows="2" class="form-control input-lg p-text-area"></textarea>
                            </form>
                            <footer class="panel-footer">
                                <button class="btn btn-danger pull-right">Post</button>
                                <ul class="nav nav-pills">
                                    <li>
                                        <a href="#"><i class="icon-map-marker"></i></a>
                                    </li>
                                    <li>
                                        <a href="#"><i class="icon-camera"></i></a>
                                    </li>
                                    <li>
                                        <a href="#"><i class=" icon-film"></i></a>
                                    </li>
                                    <li>
                                        <a href="#"><i class="icon-microphone"></i></a>
                                    </li>
                                </ul>
                            </footer>
                        </section>
                        <section class="panel  panel-primary">
                            <div class="panel-heading">
                                Your Room Info
                            </div>
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>Room ID</th>
                                        <th>Room Type</th>
                                        <th>Create Date</th>
                                        <th>End Date</th>
                                        <th>Deposit</th>
                                        <th>Operation</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <%
                                        List<Map<String, Object>> subRoomInfoList = roomManager.getSubRoomInfoByUserId((int)currentUser.get("id"));
                                        for(Map<String, Object> subRoomInfo : subRoomInfoList){
                                            Map<String, Object> roomRec = roomManager.getRoomByRoomId((int)subRoomInfo.get("rid"));
                                            Map<String, Object> roomCate = roomManager.getCategory((int)roomRec.get("category"));
                                    %>
                                    <tr>
                                        <td><%=roomRec.get("id") %></td>
                                        <td><%=roomCate.get("title") %></td>
                                        <td><%=subRoomInfo.get("create_date") %></td>
                                        <td><%=subRoomInfo.get("end_date") %></td>
                                        <td>$ <%=subRoomInfo.get("deposit") %></td>
                                        <td>
                                            <button type="button" class="btn btn-info btn-xs" data-toggle="modal" href="#roomSubAlert">Renewal</button>
                                            <button type="button" class="btn btn-danger btn-xs" data-toggle="modal" href="#roomCheckoutAlert">Check-out</button>
                                        </td>
                                    </tr>
                                    <%
                                        }
                                    %>
                                </tbody>
                            </table>
                            <!--modal -->
                            <div class="modal fade" id="roomSubAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title">Alert</h4>
                                        </div>
                                        <div class="modal-body">

                                            You need go to foreground to <strong>RENEWAL</strong> your room.

                                        </div>
                                        <div class="modal-footer">
                                            <button data-dismiss="modal" class="btn btn-danger" type="button">Close</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="modal fade" id="roomCheckoutAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title">Alert</h4>
                                        </div>
                                        <div class="modal-body">

                                            You need go to foreground to <strong>CHECK-OUT</strong> your room.

                                        </div>
                                        <div class="modal-footer">
                                            <button data-dismiss="modal" class="btn btn-danger" type="button">Close</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--modal end-->
                        </section>
                        <section class="panel  panel-primary">
                            <header class="panel-heading">
                                Your Consume Info
                            </header>
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>Consume Name</th>
                                        <th>Consume Type</th>
                                        <th>Num</th>
                                        <th>Create Date</th>
                                        <th>Deposit</th>
                                        <th>Is Order</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <%
                                        List<Map<String, Object>> consumeInfoList = consumeManager.getConsumeInfoListByUserId((int)currentUser.get("id"));
                                        for(Map<String, Object> consumeInfo : consumeInfoList){
                                            Map<String, Object> consumeRec = consumeManager.getConsume((int)consumeInfo.get("cid"));
                                            Map<String, Object> consumeCate = consumeManager.getConsumeCategoryByCategoryId((int)consumeRec.get("category"));
                                    %>
                                    <tr>
                                        <td><%=consumeRec.get("title") %></td>
                                        <td><%=consumeCate.get("title") %></td>
                                        <td><%=consumeInfo.get("num") %></td>
                                        <td><%=consumeInfo.get("create_date") %></td>
                                        <td>$ <%=consumeInfo.get("deposit") %></td>
                                        <td>
                                            <%
                                                Boolean is_order = (Boolean)consumeInfo.get("is_order");
                                                if(is_order){
                                                    
                                            %>
                                                <span class="label label-success">Yes</span>
                                            <%
                                                }else{
                                            %>
                                                <span class="label label-danger">No</span>
                                            <%
                                                }
                                            %>
                                        </td>
                                    </tr>
                                    <%
                                        }
                                    %>
                                </tbody>
                            </table>
                        </section>
                    </aside>
                </div>

                <!-- page end-->
            </section>
        </section>
        <!--main content end-->
    </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="../Public/js/jquery.js"></script>
    <script src="../Public/js/bootstrap.min.js"></script>
    <script src="../Public/js/jquery.scrollTo.min.js"></script>
    <script src="../Public/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="../Public/assets/jquery-knob/js/jquery.knob.js"></script>

    <!--common script for all pages-->
    <script src="../Public/js/common-scripts.js"></script>

    <script>
        //knob
      $(".knob").knob();
    </script>
    
    <!--scripted by myself-->
    <script>
        $(document).ready(function(){
            $("#User_Oprt").addClass("active");
            $("#hotel_user").addClass("active");
        });
    </script>


</body>

</html>
<%
    }
%>